package djboom.materials.display.elements {
	import org.casalib.display.CasaShape;
	import org.casalib.display.CasaSprite;

	import flash.events.Event;
	import flash.filters.DropShadowFilter;

	/**
	 * .
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 20.05.2010
	 * 
	 */

	public class SamplePlace extends CasaSprite {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		private static const DROP_SHADOW:DropShadowFilter = new DropShadowFilter(2, 75, 0, 0.75, 2, 2, 1, 1, true, false, true);

		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		private var _fillShape:CasaShape;
		private var _borderShape:CasaShape;
		private var _dropShadowShape:CasaShape;

		private var _free:Boolean = true;

		private var _draggedSample:SampleDragged;

		
		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function SamplePlace() {
			super();
            
			_fillShape = new CasaShape(); 
			_fillShape.graphics.beginFill(0xffffff, 0.7);
			_fillShape.graphics.moveTo(37, 5);
			_fillShape.graphics.lineTo(101, 5);
			_fillShape.graphics.lineTo(132, 58);			_fillShape.graphics.lineTo(132, 60);
			_fillShape.graphics.lineTo(101, 113);
			_fillShape.graphics.lineTo(37, 113);
			_fillShape.graphics.lineTo(6, 60);			_fillShape.graphics.lineTo(6, 58);
			_fillShape.graphics.lineTo(37, 5);            
			_fillShape.graphics.endFill();
			_fillShape.alpha = 0.75;
			addChild(_fillShape);
			
			_dropShadowShape = new CasaShape(); 
			_dropShadowShape.graphics.beginFill(0xffffff);
			_dropShadowShape.graphics.moveTo(37, 5);
			_dropShadowShape.graphics.lineTo(101, 5);
			_dropShadowShape.graphics.lineTo(132, 58);
			_dropShadowShape.graphics.lineTo(132, 60);
			_dropShadowShape.graphics.lineTo(101, 113);
			_dropShadowShape.graphics.lineTo(37, 113);
			_dropShadowShape.graphics.lineTo(6, 60);
			_dropShadowShape.graphics.lineTo(6, 58);
			_dropShadowShape.graphics.lineTo(37, 5);            
			_dropShadowShape.graphics.endFill();
			_dropShadowShape.alpha = 0.75;
			_dropShadowShape.filters = [DROP_SHADOW];
			addChild(_dropShadowShape);
            
			_borderShape = new CasaShape();  
			_borderShape.graphics.beginFill(0x888888);
			_borderShape.graphics.moveTo(35, 0);
			_borderShape.graphics.lineTo(103, 0);
			_borderShape.graphics.lineTo(138, 58);			_borderShape.graphics.lineTo(138, 60);
			_borderShape.graphics.lineTo(103, 118);
			_borderShape.graphics.lineTo(35, 118);
			_borderShape.graphics.lineTo(0, 60);			_borderShape.graphics.lineTo(0, 58);
			_borderShape.graphics.lineTo(35, 0);
            
			_borderShape.graphics.moveTo(37, 5);
			_borderShape.graphics.lineTo(101, 5);
			_borderShape.graphics.lineTo(132, 58);
			_borderShape.graphics.lineTo(132, 60);
			_borderShape.graphics.lineTo(101, 113);
			_borderShape.graphics.lineTo(37, 113);
			_borderShape.graphics.lineTo(6, 60);
			_borderShape.graphics.lineTo(6, 58);
			_borderShape.graphics.lineTo(37, 5);
            
			_borderShape.graphics.lineTo(35, 0);
			_borderShape.graphics.endFill();
			_borderShape.alpha = 0.4;
			addChild(_borderShape);
			
			addEventListener(Event.REMOVED_FROM_STAGE, clearContent);
		}	 

		// ----------------------------------------------------------------------------
		// Методы класса.
		// ----------------------------------------------------------------------------

		private function clearContent(event:Event):void {
			_fillShape.destroy();
			_fillShape = null;
        
			_borderShape.destroy();
			_borderShape = null;
        
			_dropShadowShape.destroy();
			_dropShadowShape = null;
		}

		
		
		// ----------------------------------------------------------------------------
		// Публичные методы.
		// ----------------------------------------------------------------------------
			
		// ----------------------------------------------------------------------------
		// Публичные свойства.
		// ----------------------------------------------------------------------------

		public function get free():Boolean {
			return _free;
		}

		public function set free(free:Boolean):void {
			_free = free;
		}

		public function get draggedSample():SampleDragged {
			return _draggedSample;
		}

		public function set draggedSample(draggedSample:SampleDragged):void {
			_draggedSample = draggedSample;
		}
	}
}
